package genetic.q3.functions;

import genetic.Function;
import genetic.TreeNode;

public class Minus extends SymbolicRegressionFunction{

	public Minus() {
		super(null);
	}
	
	public Minus(TreeNode[] kids) {
		super(kids);
	}

	@Override
	public Function createInstance(TreeNode[] kids) {
		return new Minus(kids);
	}

	@Override
	public TreeNode createRandomInstance(TreeNode[] kids) {
		return new Minus(kids);
	}

	@Override
	public int getNumKids() {
		return 2;
	}

	@Override
	public String getName() {
		return "-";
	}

	@Override
	public double compute(double xVal) {
		double val1 = ((Computable)kids[0]).compute(xVal);
		double val2 = ((Computable)kids[1]).compute(xVal);
		return val1-val2;
	}

}
